/**
 * Created by waterworld on 17-7-21.
 */


var  multi_10dianban=2;
var  multi_5baopai=2;
var  multi_wuxiao=2;
var  multi_10dianban_wuxiao=4;
var  multi_5hua=8;

//五花改成八倍
//五张爆牌输家出2倍
var core_10dban=function()
{

};

core_10dban.prototype.cardTypeInfo=function(cards)
{
    var len=cards.length;
    var isBaoPai=false;
    var dian=0;
    var  huaCount=0;
    var  ret={isBaoPai:0,wuhua:0,wuXaio:0,c10dianban:0,dian:0,wuxiao_10dianban:0,power:0,maxFen:1,maxFen1:0,type:'单牌'};
    //单牌,10点半 ,五小，五花，五小十点半
    for(var i=0;i<len;i++)
    {   var card=cards[i];
        dian=dian+card.dian;
        if(card.dian==0.5) huaCount++;
    }
    ret.dian=dian;
    if(dian>10.5)
    {   ret.isBaoPai=1;
        ret.power=-1;
        ret.type='爆牌';
        if(len==5)
        {ret.maxFen=multi_5baopai;
        ret.maxFen1=multi_5baopai;
        }
    }
    else
    {ret.power=dian;}
    if(dian==10.5&&len<5)
    {ret.c10dianban=multi_10dianban;
    ret.power=ret.power+multi_10dianban*10;
        ret.maxFen=multi_10dianban;
        console.logg('出现十点半 翻',multi_10dianban,'倍');
        ret.type='十点半';
    }
    //五小两倍
    if(dian<10.5&&len==5) {console.logg('出现五小 翻',multi_wuxiao,'倍');
        ret.wuXiao=multi_wuxiao;ret.power=ret.power+multi_wuxiao*20; ret.maxFen=multi_wuxiao;
        ret.type='五小';
    }
    //十点半五小 四倍
    if(dian==10.5&&len==5)  {console.logg('出现十点半五小 翻',multi_10dianban_wuxiao,'倍');
        ret.wuxiao_10dianban=multi_10dianban_wuxiao;ret.power=ret.power+multi_10dianban_wuxiao*20;ret.maxFen=multi_10dianban_wuxiao;
        ret.type='五小十点半';
    }
    //五花八倍
    if(dian<10.5&&huaCount==5) {console.logg('出现五花  翻',multi_5hua,'倍');
        ret.wuhua=multi_5hua;ret.power=ret.power+multi_5hua*40;ret.maxFen=multi_5hua;
        ret.type='人五小';
    }
    return ret;
};

core_10dban.prototype.compareCard=function(cardsZhuang,cardsNormal)
{
    var info1=this.cardTypeInfo(cardsZhuang);
    var info2=this.cardTypeInfo(cardsNormal);
    console.logg('compareCard power ',info1.power,info2.power);
    if(info1.power>=info2.power)
    {   var maxFen=info1.maxFen;
        if(info1.maxFen1<info2.maxFen1&&info2.maxFen1>maxFen)  maxFen=info2.maxFen1;
        return [maxFen,maxFen*-1,info1,info2]; }
    var maxFen=info2.maxFen;
    //闲家赢了庄家,判断5张爆牌的情况
    if(info1.maxFen1>info2.maxFen1&&maxFen<info1.maxFen1)  maxFen=info1.maxFen1;
    return [maxFen*-1,maxFen,info1,info2];
};

module.exports=core_10dban;
